package com.controller.lzj;


import com.bean.lzj.Car;
import com.bean.lzj.TruckSpace;
import com.bean.lzj.Result;
import com.bean.lzj.Xiaoqu;
import com.dao.lzj.TruckSpaceDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;
import java.util.List;

/**
 * 处理车位信息
 */
@Controller

@ResponseBody
@RequestMapping("/LzjPage/")
public class TruckSpaceController {
    /**
     * \
     * 查询车位信息
     *
     * @throws SQLException
     */
    @Autowired
    private TruckSpaceDao truckSpaceDao;

    /**
     * 给小区赋值
     * @return
     * @throws SQLException
     */

    @RequestMapping(value = "getxiaoqu", method = RequestMethod.GET)
    @ResponseBody
    public List<TruckSpace> getxq() throws SQLException {
        List<TruckSpace> xq = TruckSpaceDao.getxq();
        return xq;
    }

    /**
     * 查询车位信息
     * @return
     * @throws SQLException
     */
    @RequestMapping(value = "getcw", method = RequestMethod.GET)
    @ResponseBody
    public List<TruckSpace> getCw() throws SQLException {
        List<TruckSpace> cw = TruckSpaceDao.getCw();
        return cw;
    }

    /**
     * 根据id删除车位
     *
     * @param pid
     * @return
     */
    @RequestMapping("deleteCwxx")
    @ResponseBody
    public Result deleteCwxxById(int pid) {
        System.out.println(pid);
        boolean result = TruckSpaceDao.deleteCwxxById(pid);
        Result rs = new Result();
        rs.setOk(result);
        return rs;
    }

    /**
     * 综合查询
     *
     * @param ssxqxl
     * @param cwztxl
     * @param cwbhxl
     * @return
     * @throws SQLException
     */
    @RequestMapping("cwxxzhcx")
    @ResponseBody

    public List<TruckSpace> Cwzhxx(String ssxqxl, String cwztxl, String cwbhxl) throws SQLException {

        List<TruckSpace> cw = TruckSpaceDao.getCwzhxx(ssxqxl, cwztxl, cwbhxl);
        return cw;
    }

    /**
     * 批量删除
     *
     * @param fxk
     * @return
     */
    @RequestMapping("deleteinbatches")
    @ResponseBody
    public Result deleteinbatchesById(int fxk) {
        boolean result = TruckSpaceDao.deleteinbatchesById(fxk);
        Result rs = new Result();
        rs.setOk(result);
        return rs;
    }

    @RequestMapping("/tianjia")
    @ResponseBody
    public Result gettianjia(String xq, String cwmj, String cwlx, String whsfbz, String bz) {
        boolean result = TruckSpaceDao.gettianjia(xq, cwmj, cwlx, Integer.parseInt(whsfbz), bz);
        Result rs = new Result();
        rs.setOk(result);
        return rs;


    }

    @RequestMapping("chaxunchewei")
    @ResponseBody
    public List<Car> getzhxxcx(int pid) throws SQLException {
        List<Car> cl = truckSpaceDao.getzhxxcx(pid);
        return cl;
    }


    @RequestMapping("xiugaixinxi")
    @ResponseBody

    public Result getxiugaixinxi( int pid,String xgxq, String xgcwlx, String xgcwzt,String xgcwmj ,String xgsfbz, String xgbz) {
        boolean result = TruckSpaceDao.getxiugaixinxi(pid, xgxq, xgcwlx, xgcwzt, xgcwmj,xgsfbz,xgbz);
        Result rs = new Result();
        rs.setOk(result);
        return rs;


    }
/**
 * 修改前先查询数据库，赋值给输入框
 */


    @RequestMapping("xiugaixinxichaxun")
    @ResponseBody

    public List<TruckSpace> Cwzhxx(int pid) throws SQLException {

        List<TruckSpace> cw = TruckSpaceDao.getCwzhxxcx(pid);
        return cw;
    }

}


